/******************************************************************************

	COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2010.

	This file is part of Maxsi Engine.

	Maxsi Engine is free software: you can redistribute it and/or modify it
	under the terms of the GNU Lesser General Public License as published by
	the Free Software Foundation, either version 3 of the License, or (at your
	option) any later version.

	Maxsi engine is distributed in the hope that it will be useful, but WITHOUT
	ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
	FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
	for more details.

	You should have received a copy of the GNU Lesser General Public License
	along with Maxsi Engine. If not, see <http://www.gnu.org/licenses/>.

	MaxsiEngine.dll
	A general purpose C++ library for the Maxsi Technology Project.

	MaxsiMinGWHacks.cpp
	Hacks so MinGW can compile this correctly!

******************************************************************************/

#include "MaxsiEngine.h"

#ifdef __MINGW_H // Hacks to make Maxsi Engine compile using MinGW

BeginMaxsiNamespace

HMODULE		libkernel32		=	NULL;

#ifdef Hack_BindIoCompletionCallback
LPBindIoCompletionCallback	Func_BindIoCompletionCallback	=	NULL;

LINK BOOL BindIoCompletionCallback(HANDLE FileHandle, LPOVERLAPPED_COMPLETION_ROUTINE Function, ULONG Flags)
{
	if ( Func_BindIoCompletionCallback )
	{
		return Func_BindIoCompletionCallback(FileHandle, Function, Flags);
	}
	else
	{
		if ( !libkernel32 )
		{
			libkernel32		=	LoadLibraryA("kernel32.dll");
			
			if ( !libkernel32 )
			{
				return FALSE;
			}
		}

		Func_BindIoCompletionCallback = reinterpret_cast<LPBindIoCompletionCallback>(GetProcAddress(libkernel32, "BindIoCompletionCallback" ));

		if ( !Func_BindIoCompletionCallback ) { return FALSE; }

		return Func_BindIoCompletionCallback(FileHandle, Function, Flags);
	}
}
#endif

EndMaxsiNamespace

#endif

